import {
  MongoClient
} from 'mongodb';
import {
  mongoConfig
} from './default.js';
const mongoDB = new MongoClient(mongoConfig.url);

let db;

async function mainFun() {
  // 创建MongoDB连接
  try {
    await mongoDB.connect();
    console.log('Connected to MongoDB successfully');
    db = mongoDB.db(mongoConfig.dbName);

  } catch (err) {
    console.log('Connected to MongoDB failed', err);
  }

}

export {
  mainFun,
  db
}